@extends('backend.template.bootstrap')
@section('content')
<div id="page-wrapper" >
    <div id="page-inner">
        <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">
                    分类管理 <small>Categories.</small>
                </h1>
            </div>
        </div>
        <!-- /. ROW  -->
        <div class="row">
            <div class="col-md-12">
                <!-- Advanced Tables -->
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="panel-body">
                            <a href="{{ url('backend/categories/create') }}" class="btn btn-primary"><li class="fa fa-edit"></li> 添加分类</a>
                            <br />
                            <br />
                            <div class="table-responsive">
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th>排序</th>
                                        <th>分类类型</th>
                                        <th>名称</th>
                                        <th>状态</th>
                                        <th>创建时间</th>
                                        <th width="12%">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @foreach($categories as $category)
                                        <tr class="">
                                            <td>{{ $category->order }}</td>
                                            <td>{{ $category->type_ex() }}</td>
                                            <td>{{ $category->name }}</td>
                                            <td>{{ $category->getState() }}</td>
                                            <td>{{ $category->created_at }}</td>
                                            <td>
                                                <a class="btn btn-sm btn-default" href="{{ url('backend/categories/'. $category->id .'/edit') }}">编辑</a> 
                            					{!! Form::open(array('method' => 'post', 'url' => 'backend/categories/'. $category->id .'/change-state', 'style' => 'display:inline-block;')) !!}
                            						@if($category->disabled)
                            							{!! Form::hidden('disabled', false) !!}	
                                                		<button type="submit" class="btn btn-sm btn-success">启用</button>
                            						@else
                            							{!! Form::hidden('disabled', true) !!}
                                                		<button type="submit" class="btn btn-sm btn-warning">禁用</button>
                            						@endif 
                                                {!! Form::close() !!}
<!--                                                 {!! Form::open(array('method' => 'delete', 'url' => 'backend/categories/'. $category->id, 'style' => 'display:inline-block;', 'onSubmit' => 'return confirm("确认删除？删除后不可恢复！")')) !!} -->
<!--                                                 <button type="submit" class="btn btn-sm btn-danger">删除</button> -->
<!--                                                 {!! Form::close() !!} -->
                                            </td>
                                        </tr>
                                    @endforeach
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <!--End Advanced Tables -->
            </div>
        </div>
    </div>
    <!-- /. PAGE INNER  -->

</div>
@endsection